package com.wenxixuanwu.fruitstore.controller;

import com.wenxixuanwu.fruitstore.entity.Form;
import com.wenxixuanwu.fruitstore.entity.OrderList;
import com.wenxixuanwu.fruitstore.mapper.OrderMapper;
import com.wenxixuanwu.fruitstore.service.OrderService;
import com.wenxixuanwu.fruitstore.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.jar.JarEntry;

@RestController
@RequestMapping("/order")
public class OrderController extends BaseController{

    @Autowired
    private OrderService orderService;

    @GetMapping("/create")
    public JsonResult<OrderList> create(Integer[] cid, HttpSession session){
        OrderList data = orderService.create(cid, session);
        return new JsonResult<OrderList>(OK,data);
    }

    @GetMapping("/addOrder")
    public List addOrder(HttpSession session){
        UUID orderId = UUID.randomUUID();
        List list = new ArrayList();
        list.add(session.getAttribute("u"));
        list.add(orderId);
        System.out.println(list);
        return list;
    }

    @PostMapping("/insert")
    public void insert(@RequestBody Form form){
        System.out.println("form = " + form);
    }
}
